package org.jeecg.modules.rooms.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.Enum.ResultCode;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.rooms.DTO.CesGoodStockRecordsDto;
import org.jeecg.modules.rooms.service.CesGoodStockRecordsServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 商品进退货记录表 前端控制器
 * </p>
 *
 * @author fendo
 * @since 2023-03-14
 */
@RestController
@RequestMapping("/rooms/cesGoodStockRecords")
@Api(tags="CesGoodStockRecordsController")
@Slf4j
public class CesGoodStockRecordsController {

    @Resource
    private CesGoodStockRecordsServiceImpl stockRecordsService;


    @AutoLog(value = "创建")
    @ApiOperation(value="创建", notes="创建")
    @PostMapping(value = "/create")
    public Result create(@RequestBody CesGoodStockRecordsDto dto){
        if(StringUtils.isBlank(dto.getGoodId())){
            return Result.error(ResultCode.PARAM_MISS);
        }
        if(StringUtils.isBlank(dto.getHotelId())){
            return Result.error(ResultCode.PARAM_MISS);
        }
        if(StringUtils.isBlank(dto.getHotelId())){
            return Result.error(ResultCode.PARAM_MISS);
        }
        if(dto.getGoodNum().intValue() < 0){
            return Result.error(ResultCode.PARAM_MISS);
        }
        return stockRecordsService.create(dto);
    }

}

